{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ###  [faceplusplus文档中心](https://console.faceplusplus.com.cn/documents/4888373)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# faceplusplus人脸检测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "400\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'request_id': '1679662350,119e47e8-d6f3-4c4b-b79e-22d6a8f70e32',\n",
       " 'time_used': 6,\n",
       " 'error_message': 'BAD_ARGUMENTS: return_attributes'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face＋＋人脸识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('D:\\图片\\cxk.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\n",
    "    \"api_key\":\"aNzTXLaR4VKLdXyR-ulxjjvqacC5CvqF\",\n",
    "    \"api_secret\":\"SyLp194J1PQIATX0Rt7yLuFA5vCh1NEC\",\n",
    "    \"image_base64\":img,\n",
    "    \"return_attributes\":\"gender,age,smilimg,emotion,beauty\"\n",
    "}\n",
    "\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "print(response.status_code)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "400\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'request_id': '1679662484,3612b1d0-6abc-41e3-9342-1d451af5bac4',\n",
       " 'time_used': 72,\n",
       " 'error_message': 'BAD_ARGUMENTS: return_attributes'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face＋＋人脸识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('D:\\图片\\cxk.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\n",
    "    \"api_key\":\"aNzTXLaR4VKLdXyR-ulxjjvqacC5CvqF\",\n",
    "    \"api_secret\":\"SyLp194J1PQIATX0Rt7yLuFA5vCh1NEC\",\n",
    "    \"image_base64\":img,\n",
    "    \"return_attributes\":\"gender,age,smilimg,emotion,beauty\"\n",
    "}\n",
    "\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "print(response.status_code)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
